<template>
	<view class="jobDetail">
		<u-swiper :list="jobInfo.tbEnterprise.tbPhotoList" keyName="photoUrl"></u-swiper>
		<view class="companyName">
			{{jobInfo.tbEnterprise.name}}
		</view>
		<view class="number">
			工商注册号：{{jobInfo.tbEnterprise.registrationNo}}
		</view>
		<view class="">
			<view class="title">
				岗位介绍
			</view>
			<view class="infoBox">
				<view class="infoItem">
					<text class="left">职位名称</text>
					<text class="right">{{jobInfo.title}}</text>
				</view>
				<!-- <view class="infoItem">
					<text class="left">年龄</text>
					<text class="right">{{}}</text>
				</view> -->
				<!-- <view class="infoItem">
					<text class="left">学历</text>
					<text class="right">本科</text>
				</view> -->
				<view class="infoItem">
					<text class="left">招聘人数</text>
					<text class="right">{{jobInfo.peopleNum}}</text>
				</view>
				<view class="infoItem">
					<text class="left">工作地点</text>
					<text class="right">{{jobInfo.workAddress }}</text>
				</view>
				<view class="infoItem">
					<text class="left salary">工资薪水</text>
					<text class="right salary">{{ jobInfo.minSalary+'-'+jobInfo.maxSalary+'k' }}</text>
				</view>
			</view>
			<view class="descBox">
				<view class="title2">
					更多职位描述
				</view>
				<view class="desc">
					{{ jobInfo.desc }}
				</view>
			</view>
		</view>
		<view class="">
			<view class="title">
				企业介绍
			</view>
			<view class="infoBox">
				<view class="infoItem">
					<text class="left">企业性质</text>
					<text class="right">{{jobInfo.tbEnterprise.tbEnNature.name}}</text>
				</view>
				<view class="infoItem">
					<text class="left">企业电话</text>
					<text class="right">{{jobInfo.tbEnterprise.enPhone}}</text>
				</view>
				<view class="infoItem infoItem2 ">
					<view class="left" style="margin-bottom: 30upx;">企业地址</view>
					<view class="right">{{jobInfo.tbEnterprise.address}}</view>
				</view>

			</view>
			<view class="descBox">
				<view class="title2">
					更多企业描述
					<view class="desc">
						{{ jobInfo.tbEnterprise.desc }}
					</view>
				</view>
			</view>
		</view>
		<button type="default" @tap="jumpChatPrivate()">联系企业</button>
	</view>
</template>

<script>
	import {
		saveUserLog
	} from '@/api/index.js'
	import {
		findUserByEnterprise
	} from "../../api/user.js"
	import {
		ApiGetRecruitmentInfo
	} from '@/api/jobDetail.js'
	import {
		Toast
	} from '../../common/common.js'
	export default {
		data() {
			return {
				jobId: 0,
				jobInfo: {},
				user:{}
			}
		},
		onLoad(options) {
			this.jobId = options.jobId || 0
			console.log(this.jobId)
			this.getRecruitmentInfo()
		},
		onShow() {
			this.getRecruitmentInfo()
		},
		methods: {
			findUserByEnterprise(){
				findUserByEnterprise({"id":this.jobInfo.enterpriseId}).then(res=>{
					this.user = res.data.data
					getApp().globalData.friend = this.user
				})
			},
			jumpChatPrivate() {
				let token = uni.getStorageSync("token");
				console.log(token)
				if (token == ''){
					Toast({title:"联系企业需要登录哟!"})
					return
				}else{
					let user = uni.getStorageSync('user');
					if(token!=''){
						saveUserLog({'userId':user.id,'infoId':this.jobId,'score':2})
					}
				}
				uni.navigateTo({
					url:`/pages/chat/privateChat?to=${this.user.id}`
				})
			},
			//ApiGetRecruitmentInfo
			getRecruitmentInfo() {
				ApiGetRecruitmentInfo({
					"jobId": this.jobId
				}).then(res => {
					console.log(res)
					if (res.data.code == 20000) {
						this.jobInfo = res.data.data
						this.findUserByEnterprise()
					} else {
						Toast({
							title: '查询失败'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.jobDetail {
		min-height: 100vh;

		.bgImg {
			width: 100%;
			height: 200rpx;
			background: #F1F1F1;
		}

		.companyName {
			color: red;
			margin-bottom: 20upx;
			font-size: 32upx;
			font-weight: 600;
			text-align: center;
		}

		.number {
			margin-bottom: 20upx;
			font-size: 30upx;
			color: #999;
			text-align: center;
			padding-bottom: 30upx;
			border-bottom: 2upx solid #f4f4f4;
		}

		.title {
			color: red;
			margin-top: 30upx;
			margin-bottom: 30upx;
			font-size: 32upx;
			font-weight: 600;
			text-align: center;
		}

		.infoBox {
			background: #FFFFFF;
			padding: 30upx;
			padding-top: 0;

			.infoItem {
				display: flex;
				justify-content: space-between;
				padding: 30upx 0;
				border-bottom: 2upx solid #f4f4f4;

				.left {
					color: #343434;
				}

				.right {
					color: #999;
				}

				.salary {
					color: red;
					font-weight: 600;
				}
			}

			.infoItem2 {
				padding: 30upx 0;
				border-bottom: 2upx solid #f4f4f4;
				display: block;
			}
		}

		.descBox {
			background: #FFFFFF;
			padding: 30upx;
			padding-top: 0;
			margin-bottom: 30upx;
			border-bottom: 2upx solid #f4f4f4;

			.title2 {
				font-weight: 600;
				font-size: 32upx;
				margin-bottom: 30upx;
				color: #343434;
			}

			.desc {
				font-size: 28upx;
				line-height: 48upx;
				color: #343434;
			}
		}

		.companyImg {
			width: 300upx;
			height: 200upx;
			margin: 0 30upx;
		}
	}
</style>
